{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0.          0.84147098  0.90929743  0.14112001]\n",
      " [-0.7568025  -0.95892427 -0.2794155   0.6569866 ]\n",
      " [ 0.98935825  0.41211849 -0.54402111 -0.99999021]\n",
      " [-0.53657292  0.42016704  0.99060736  0.65028784]\n",
      " [-0.28790332 -0.96139749 -0.75098725  0.14987721]]\n",
      "[2 0 3 1]\n",
      "[ 0.98935825  0.84147098  0.99060736  0.6569866 ]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "data = np.sin(np.arange(20)).reshape(5,4)\n",
    "print (data)\n",
    "ind = data.argmax(axis=0)\n",
    "print (ind)\n",
    "data_max = data[ind, range(data.shape[1])]\n",
    "print (data_max)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0 10 20 30]\n",
      "[[ 0 10 20 30  0 10 20 30  0 10 20 30]\n",
      " [ 0 10 20 30  0 10 20 30  0 10 20 30]\n",
      " [ 0 10 20 30  0 10 20 30  0 10 20 30]\n",
      " [ 0 10 20 30  0 10 20 30  0 10 20 30]]\n"
     ]
    }
   ],
   "source": [
    "a = np.arange(0, 40, 10)\n",
    "print (a)\n",
    "b = np.tile(a, (4, 3)) \n",
    "print (b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[4 3 5]\n",
      " [1 2 1]]\n",
      "--------\n",
      "[[3 4 5]\n",
      " [1 1 2]]\n",
      "--------\n",
      "[[3 4 5]\n",
      " [1 1 2]]\n",
      "--------\n",
      "[2 3 1 0]\n",
      "--------\n",
      "[1 2 3 4]\n"
     ]
    }
   ],
   "source": [
    "a = np.array([[4, 3, 5], [1, 2, 1]])\n",
    "print (a)\n",
    "print ('--------')\n",
    "b = np.sort(a, axis=1)\n",
    "print (b)\n",
    "#b\n",
    "a.sort(axis=1)\n",
    "print ('--------')\n",
    "print (a)\n",
    "a = np.array([4, 3, 1, 2])\n",
    "j = np.argsort(a)\n",
    "print ('--------')\n",
    "print (j)\n",
    "print ('--------')\n",
    "print (a[j])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
